package com.yc.baihe.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.yc.baihe.beans.BhUser;
import com.yc.baihe.beans.UserList;
import com.yc.baihe.beans.UserPrivate;
import com.yc.baihe.biz.IUserListBiz;
import com.yc.baihe.biz.IuserPrivateBiz;
import com.yc.baihe.biz.impl.UserListBizImpl;
import com.yc.baihe.biz.impl.UserPrivateBizImpl;
import com.yc.baihe.utils.Reflect;
import com.yc.baihe.utils.SessionAttributeNames;




public class MybaiheServlet extends CommonServlet {
	private static final long serialVersionUID = 1L;
	private IUserListBiz usersInfoBiz=new UserListBizImpl();
	IuserPrivateBiz userprivate=new UserPrivateBizImpl();
	private PrintWriter out;
	private HttpSession session;
	
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		super.doPost(request, response);
		String op=request.getParameter("op");
		
		out=response.getWriter();
		session=request.getSession();
		
		if("ziliaoInfo".equals(op)){//个人资料保存
			ziliaoInfo(request,response);
		}
	}

	private void ziliaoInfo(HttpServletRequest request,HttpServletResponse response) {
		UserList adminInfo=Reflect.regInfo(request,UserList.class);
		UserPrivate up=Reflect.regInfo(request,UserPrivate.class);
		BhUser bh=(BhUser) session.getAttribute(SessionAttributeNames.CURRENTUSERSINFO);
		int buid=bh.getBuid();
		adminInfo.setBuid(buid);
		System.out.println(buid);
		if(up!=null){
			userprivate.addUserPrivate(up);
		}
		out.print(usersInfoBiz.addUserList(adminInfo));
		out.flush();
		out.close();
	}

}
